package br.com.ozsolucoes.sessionbeans;

import java.io.Serializable;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.ozsolucoes.entity.Documento;

@Stateless
public class DocumentoSessionBean implements Serializable {

	private static final long serialVersionUID = 3229019636813424436L;

	@PersistenceContext
	private EntityManager entityManager;

	public Documento consultarPorId(long idDocumento) {
		Query query = entityManager.createNamedQuery("Documento.consultarPorId");
		query.setParameter("idDocumento", idDocumento);
		try {
			return (Documento) query.getSingleResult();
		} catch (NoResultException e) {
			return null;
		}
	}

}
